<!-- *** START OF STYLESHEET *** -->

<!-- **********************************************************************
 XSL to format the search output for Google Search Appliance
 Handheld Media Version (20 July 2006)
     ********************************************************************** -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
	
<!-- **********************************************************************
 include customer-onebox.xsl, which is auto-generated from the customer's
 set of OneBox Module definitions, and in turn invokes either the default
 OneBox template, or the customer's:
********************************************************************** -->
<xsl:include href="customer-onebox.xsl"/>

<xsl:output method="xml" omit-xml-declaration="no" indent="no"/>
<xsl:strip-space elements="*"/>

<!-- **********************************************************************
 Logo setup (can be customized)
     - whether to show logo: 0 for FALSE, 1 (or non-zero) for TRUE
     - logo url
     - logo size: '' for default image size
     ********************************************************************** -->
<xsl:variable name="show_logo">1</xsl:variable>
<xsl:variable name="logo_url">http://www.google.com/xhtml/images/google.gif</xsl:variable>
<xsl:variable name="logo_width">85</xsl:variable>
<xsl:variable name="logo_height">35</xsl:variable>

<!-- **********************************************************************
 Global Style variables (can be customized): '' for using browser's default
     ********************************************************************** -->

<xsl:variable name="global_bg_color">#ffffff</xsl:variable>
<xsl:variable name="global_text_color">#000000</xsl:variable>
<xsl:variable name="global_link_color">#0000cc</xsl:variable>
<xsl:variable name="global_vlink_color">#551a8b</xsl:variable>
<xsl:variable name="global_alink_color">#ff0000</xsl:variable>


<!-- **********************************************************************
 Result page components (can be customized)
     - whether to show a component: 0 for FALSE, non-zero (e.g., 1) for TRUE
     - text and style
     ********************************************************************** -->

<!-- *** choose result page header: '', 'provided', 'mine', or 'both' *** -->
<xsl:variable name="choose_result_page_header">both</xsl:variable>

<!-- *** customize provided result page header *** -->
<xsl:variable name="show_swr_link">1</xsl:variable>
<xsl:variable name="swr_search_anchor_text">Search Within Results</xsl:variable>
<xsl:variable name="show_result_page_help_link">1</xsl:variable>
<xsl:variable name="search_help_anchor_text">Search Tips</xsl:variable>
<xsl:variable name="show_alerts_link">0</xsl:variable>
<xsl:variable name="alerts_anchor_text">Alerts</xsl:variable>

<!-- *** search boxes *** -->
<xsl:variable name="show_top_search_box">1</xsl:variable>
<xsl:variable name="show_bottom_search_box">1</xsl:variable>
<xsl:variable name="search_box_size">15</xsl:variable>

<!-- *** choose search button type: 'text' or 'image' *** -->
<xsl:variable name="choose_search_button">text</xsl:variable>
<xsl:variable name="search_button_text">Search</xsl:variable>
<xsl:variable name="search_button_image_url"></xsl:variable>
<xsl:variable name="search_collections_xslt"></xsl:variable>

<!-- *** search info bars *** -->
<xsl:variable name="show_search_info">1</xsl:variable>

<!-- *** choose separation bar: 'ltblue', 'blue', 'line', 'nothing' *** -->
<xsl:variable name="choose_sep_bar">nothing</xsl:variable>
<xsl:variable name="sep_bar_std_text">Search</xsl:variable>
<xsl:variable name="sep_bar_error_text">Error</xsl:variable>
<xsl:variable name="sep_bar_show_time">0</xsl:variable>

<!-- *** navigation bars: '', 'google', 'link', or 'simple'*** -->
<xsl:variable name="show_top_navigation">0</xsl:variable>
<xsl:variable name="choose_bottom_navigation">simple</xsl:variable>

<!-- *** sort by date/relevance *** -->
<xsl:variable name="show_sort_by">1</xsl:variable>

<!-- *** spelling suggestions *** -->
<xsl:variable name="show_spelling">1</xsl:variable>
<xsl:variable name="spelling_text">Did you mean:</xsl:variable>
<xsl:variable name="spelling_text_color">#c00</xsl:variable>

<!-- *** synonyms suggestions *** -->
<xsl:variable name="show_synonyms">1</xsl:variable>
<xsl:variable name="synonyms_text">You could also try:</xsl:variable>
<xsl:variable name="synonyms_text_color">#c00</xsl:variable>

<!-- *** keymatch suggestions *** -->
<xsl:variable name="show_keymatch">1</xsl:variable>
<xsl:variable name="keymatch_text">KeyMatch</xsl:variable>

<!-- *** Google Desktop integration *** -->
<xsl:variable name="egds_appliance_tab_label">Appliance</xsl:variable>

 <!--*** onebox information *** -->
<xsl:variable name="show_onebox">1</xsl:variable>

<!-- **********************************************************************
 Result elements (can be customized)
     - whether to show an element ('1' for yes, '0' for no)
     - font/size/color ('' for using style of the context)
     ********************************************************************** -->

<!-- *** result title and snippet *** -->
<xsl:variable name="show_res_title">1</xsl:variable>
<xsl:variable name="show_res_snippet">1</xsl:variable>
<xsl:variable name="res_snippet_size">1em</xsl:variable>
<xsl:variable name="truncate_result_snippet_length">80</xsl:variable>
<xsl:variable name="truncate_result_title_length">64</xsl:variable>

<!-- *** keyword match (in title or snippet) *** -->
<xsl:variable name="res_keyword_color"></xsl:variable>
<xsl:variable name="res_keyword_size"></xsl:variable>
<xsl:variable name="res_keyword_format"></xsl:variable>

<!-- *** link URL *** -->
<xsl:variable name="show_res_url">1</xsl:variable>
<xsl:variable name="res_url_color">#008000</xsl:variable>
<xsl:variable name="truncate_result_urls">1</xsl:variable>
<xsl:variable name="truncate_result_url_length">36</xsl:variable>

<!-- *** misc elements *** -->
<xsl:variable name="show_meta_tags">0</xsl:variable>
<xsl:variable name="show_res_size">0</xsl:variable>
<xsl:variable name="show_res_date">0</xsl:variable>
<xsl:variable name="show_res_cache">1</xsl:variable>

<!-- *** used in result cache link, similar pages link, and description *** -->
<xsl:variable name="faint_color">#77c</xsl:variable>

<!-- *** show secure results radio button *** -->
<xsl:variable name="show_secure_radio">1</xsl:variable>

<!-- **********************************************************************
 Other variables (can be customized)
     ********************************************************************** -->

<!-- *** page title *** -->
<xsl:variable name="front_page_title">Search Home</xsl:variable>
<xsl:variable name="result_page_title">Search Results</xsl:variable>
<xsl:variable name="error_page_title">Error</xsl:variable>
<xsl:variable name="swr_page_title">Search Within Results</xsl:variable>

<!-- *** cached page header text *** -->
<xsl:variable name="cached_page_header_text">This is the cached copy of</xsl:variable>

<!-- *** error message text *** -->
<xsl:variable name="server_error_msg_text">A server error has occurred.</xsl:variable>
<xsl:variable name="server_error_des_text">Check server response code in details.</xsl:variable>
<xsl:variable name="xml_error_msg_text">Unknown XML result type.</xsl:variable>
<xsl:variable name="xml_error_des_text">View page source to see the offending XML.</xsl:variable>

<!-- **********************************************************************
 My global page header/footer (can be customized)
     ********************************************************************** -->
<xsl:template name="my_page_header">
  <!-- *** replace the following with your own xhtml code or replace the text
   between the xsl:text tags with html escaped html code *** -->
  <xsl:text disable-output-escaping="yes">&lt;!-- Please enter xhtml below. --&gt;</xsl:text>
</xsl:template>

<xsl:template name="my_page_footer">
  <div>
  <span class="p">
    <xsl:text disable-output-escaping="yes">&lt;!-- Please enter xhtml below. --&gt;</xsl:text>
  </span>
  </div>
</xsl:template>


<!-- **********************************************************************
 Logo template (can be customized)
     ********************************************************************** -->
<xsl:template name="logo">
  <img src="{$logo_url}"
       width="{$logo_width}" height="{$logo_height}"
       alt="Google"/>
</xsl:template>


<!-- **********************************************************************
 Search result page header (can be customized): logo and search box
     ********************************************************************** -->
<xsl:template name="result_page_header">
  <xsl:if test="$show_logo != '0'">
    <div><xsl:call-template name="logo"/></div>
  </xsl:if>
  <xsl:if test="/GSP/CT">
    <br/>
    <xsl:call-template name="stopwords"/>
    <br/>
  </xsl:if>
</xsl:template>


<!-- **********************************************************************
 Search within results page header (can be customized): logo and search box
     ********************************************************************** -->
<xsl:template name="swr_page_header">
  <xsl:if test="$show_logo != '0'">
    <div><xsl:call-template name="logo"/></div>
  </xsl:if>
  <xsl:if test="$show_top_search_box != '0'">
    <xsl:call-template name="search_box">
      <xsl:with-param name="type" select="'swr'"/>
    </xsl:call-template>
  </xsl:if>
</xsl:template>


<!-- **********************************************************************
 Home search page header (can be customized): logo and search box
     ********************************************************************** -->
<xsl:template name="home_page_header">
  <xsl:if test="$show_logo != '0'">
    <div><xsl:call-template name="logo"/></div>
  </xsl:if>
  <xsl:if test="$show_top_search_box != '0'">
    <xsl:call-template name="search_box">
      <xsl:with-param name="type" select="'home'"/>
    </xsl:call-template>
  </xsl:if>
</xsl:template>


<!-- **********************************************************************
 Cached page header (can be customized)
     ********************************************************************** -->
<xsl:template name="cached_page_header">
  <xsl:param name="cached_page_url"/>
  <xsl:variable name="stripped_url" select="substring-after($cached_page_url,
                                                            '://')"/>
<div style="border:1px solid black;margin:auto;padding:6px;">
  <div style="border:2px solid black;padding:8px;margin:auto;background-color:{$global_bg_color};color:{$global_text_color};">
    <div class="gt">
      <xsl:value-of select="$cached_page_header_text"/>
      <xsl:call-template name="nbsp"/>
      <xsl:choose>
        <xsl:when test="starts-with($cached_page_url,
                                    $db_url_protocol)">
         <a href="{concat('/db/',$stripped_url)}">
         <xsl:value-of select="$cached_page_url"/></a>.<br/>
        </xsl:when>
        <xsl:when test="starts-with($cached_page_url,
                                    $nfs_url_protocol)">
         <a href="{concat('/nfs/',$stripped_url)}">
         <xsl:value-of select="$cached_page_url"/></a>.<br/>
        </xsl:when>
        <xsl:when test="starts-with($cached_page_url,
                                    $smb_url_protocol)">
         <a href="{concat('/smb/',$stripped_url)}">
         <xsl:value-of select="$cached_page_url"/></a>.<br/>
        </xsl:when>
        <xsl:otherwise>
         <a href="{$cached_page_url}">
         <xsl:value-of select="$cached_page_url"/></a>.<br/>
        </xsl:otherwise>
      </xsl:choose>
    </div>
  </div>
</div>
<hr/>
</xsl:template>


<!-- **********************************************************************
 "Search Within Results" search input page (can be customized)
     ********************************************************************** -->
<xsl:template name="swr_search">
  <xsl:call-template name="htmlStart"/>
  <xsl:call-template name="langHeadStart"/>
<title><xsl:value-of select="$swr_page_title"/></title>
  <xsl:call-template name="style"/>
  <xsl:call-template name="langHeadEnd"/>

<body>

  <xsl:call-template name="my_page_header"/>
  <xsl:call-template name="swr_page_header"/>

  <xsl:call-template name="copyright"/>
  <xsl:call-template name="my_page_footer"/>

</body>
  <xsl:call-template name="htmlEnd"/>
</xsl:template>


<!-- **********************************************************************
 "Front door" search input page (can be customized)
     ********************************************************************** -->
<xsl:template name="front_door">
  <xsl:call-template name="htmlStart"/>
  <xsl:call-template name="langHeadStart"/>
<title><xsl:value-of select="$front_page_title"/></title>
  <xsl:call-template name="style"/>
  <xsl:call-template name="langHeadEnd"/>

<body>

  <xsl:call-template name="my_page_header"/>
  <xsl:call-template name="home_page_header"/>

  <xsl:call-template name="copyright"/>
  <xsl:call-template name="my_page_footer"/>

</body>
  <xsl:call-template name="htmlEnd"/>
</xsl:template>


<!-- **********************************************************************
 Empty result set (can be customized)
     ********************************************************************** -->
<xsl:template name="no_RES">
  <xsl:param name="query"/>

  <p>
  Your search - <strong><xsl:value-of select="$query"/></strong> - did not match any documents.
  </p>

  <!-- *** Bottom search box *** -->
  <xsl:if test="$show_bottom_search_box != '0'">
    <xsl:call-template name="bottom_search_box"/>
  </xsl:if>
</xsl:template>


<!-- ######################################################################
 We do not recommend changes to the following code.  Google Technical
 Support Personnel currently do not support customization of XSLT under
 these Technical Support Services Guidelines.  Such services may be
 provided on a consulting basis, at Google's then-current consulting
 services rates under a separate agreement, if Google personnel are
 available.  Please ask your Google Account Manager for more details if
 you are interested in purchasing consulting services.
     ###################################################################### -->


<!-- **********************************************************************
 Global Style (do not customize)
        default font type/size/color, background color, link color
         using HTML CSS (Cascading Style Sheets)
     ********************************************************************** -->
<xsl:template name="style">
<style type="text/css">
<xsl:text disable-output-escaping="yes">
/* &lt;![CDATA[ */
</xsl:text>
<xsl:comment>
body{background-color:#fff;}
.url{color:<xsl:value-of select="$res_url_color"/>;}
.sy{color:<xsl:value-of select="$synonyms_text_color"/>;}
.sp{color:<xsl:value-of select="$spelling_text_color"/>;}
.gt{color:<xsl:value-of select="$global_text_color"/>;}
.sw{color:gray;}
img,fieldset{border:0;}
fieldset{margin:0;padding:0;}
a:link,.w,.w a:link{color:<xsl:value-of select="$global_link_color"/>}
.f,.f:link,.f a:link{color:<xsl:value-of select="$faint_color"/>}
a:visited,.f a:visited{color:<xsl:value-of select="$global_vlink_color"/>}
a:active,.f a:active{color:<xsl:value-of select="$global_alink_color"/>}
</xsl:comment>
<xsl:text disable-output-escaping="yes">
/* ]]&gt; */
</xsl:text>
</style>
</xsl:template>

<!-- **********************************************************************
 URL variables (do not customize)
     ********************************************************************** -->
<!-- *** if this is a test search (help variable)-->
<xsl:variable name="is_test_search"
  select="/GSP/PARAM[@name='testSearch']/@value"/>

<!-- *** if this is a search within results search *** -->
<xsl:variable name="swrnum">
  <xsl:choose>
    <xsl:when test="/GSP/PARAM[(@name='swrnum') and (@value!='')]">
      <xsl:value-of select="/GSP/PARAM[@name='swrnum']/@value"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="0"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:variable>

<!-- *** help_url: search tip URL (html file) *** -->
<xsl:variable name="help_url">/user_help.html</xsl:variable>

<!-- *** alerts_url: Alerts URL (html file) *** -->
<xsl:variable name="alerts_url">/alerts</xsl:variable>

<!-- *** base_url: collection info *** -->
<xsl:variable name="base_url">
  <xsl:for-each
    select="/GSP/PARAM[@name = 'client' or

                     @name = 'site' or
                     @name = 'num' or
                     @name = 'output' or
                     @name = 'proxystylesheet' or
                     @name = 'access' or
                     @name = 'lr' or
                     @name = 'ie']">
    <xsl:value-of select="@name"/>=<xsl:value-of select="@original_value"/>
    <xsl:if test="position() != last()">&amp;</xsl:if>
  </xsl:for-each>
</xsl:variable>

<!-- *** home_url: search? + collection info + &proxycustom=<HOME/> *** -->
<xsl:variable name="home_url">search?<xsl:value-of select="$base_url"
  />&amp;proxycustom=%3CHOME/%3E</xsl:variable>


<!-- *** synonym_url: does not include q, as_q, and start elements *** -->
<xsl:variable name="synonym_url"><xsl:for-each
  select="/GSP/PARAM[(@name != 'q') and
                     (@name != 'as_q') and
                     (@name != 'swrnum') and

		     (@name != 'ie') and
                     (@name != 'start') and
                     (@name != 'epoch' or $is_test_search != '') and
                     not(starts-with(@name, 'metabased_'))]">
    <xsl:value-of select="@name"/><xsl:text>=</xsl:text>
    <xsl:value-of select="@original_value"/>
    <xsl:if test="position() != last()">
      <xsl:text disable-output-escaping="yes">&amp;</xsl:text>
    </xsl:if>
  </xsl:for-each>
</xsl:variable>

<!-- *** search_url *** -->
<xsl:variable name="search_url">
  <xsl:for-each select="/GSP/PARAM[(@name != 'start') and
                                   (@name != 'swrnum') and
                     (@name != 'epoch' or $is_test_search != '') and
                     not(starts-with(@name, 'metabased_'))]">
    <xsl:value-of select="@name"/><xsl:text>=</xsl:text>
    <xsl:value-of select="@original_value"/>
    <xsl:if test="position() != last()">
      <xsl:text disable-output-escaping="yes">&amp;</xsl:text>
    </xsl:if>
  </xsl:for-each>
</xsl:variable>

<!-- *** filter_url: everything except resetting "filter=" *** -->
<xsl:variable name="filter_url">search?<xsl:for-each
  select="/GSP/PARAM[(@name != 'filter') and
                     (@name != 'epoch' or $is_test_search != '') and
                     not(starts-with(@name, 'metabased_'))]">
    <xsl:value-of select="@name"/><xsl:text>=</xsl:text>
    <xsl:value-of select="@original_value"/>
    <xsl:if test="position() != last()">
      <xsl:text disable-output-escaping="yes">&amp;</xsl:text>
    </xsl:if>
  </xsl:for-each>
  <xsl:text disable-output-escaping='yes'>&amp;filter=</xsl:text>
</xsl:variable>

<!-- *** db_url_protocol: googledb:// *** -->
<xsl:variable name="db_url_protocol">googledb://</xsl:variable>

<!-- *** nfs_url_protocol: nfs:// *** -->
<xsl:variable name="nfs_url_protocol">nfs://</xsl:variable>

<!-- *** smb_url_protocol: smb:// *** -->
<xsl:variable name="smb_url_protocol">smb://</xsl:variable>

<!-- *** swr_search_url: search? + $search_url + as_q=$q *** -->
<xsl:variable name="swr_search_url">search?<xsl:value-of
  select="$search_url"/>&amp;swrnum=<xsl:value-of select="/GSP/RES/M"/></xsl:variable>

<!-- **********************************************************************
 Search Parameters (do not customize)
     ********************************************************************** -->

<!-- *** num_results: actual num_results per page *** -->
<xsl:variable name="num_results">
  <xsl:choose>
    <xsl:when test="/GSP/PARAM[(@name='num') and (@value!='')]">
      <xsl:value-of select="/GSP/PARAM[@name='num']/@value"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="10"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:variable>

<!-- *** form_params: parameters carried by the search input form *** -->
<xsl:template name="form_params">
  <xsl:for-each
    select="PARAM[@name != 'q' and
                  @name != 'ie' and
                  not(contains(@name, 'as_')) and
                  @name != 'btnG' and
                  @name != 'btnI' and
                  @name != 'site' and
                  @name != 'filter' and
                  @name != 'swrnum' and
                  @name != 'start' and
                  @name != 'access' and
                  @name != 'ip' and
                  (@name != 'epoch' or $is_test_search != '') and
                  not(starts-with(@name ,'metabased_'))]">
<input type="hidden" name="{@name}" value="{@value}" />

      <xsl:if test="@name = 'oe'">
<input type="hidden" name="ie" value="{@value}" />
      </xsl:if>
  </xsl:for-each>
  <xsl:if test="$search_collections_xslt = '' and PARAM[@name='site']">
<input type="hidden" name="site" value="{PARAM[@name='site']/@value}"/>
  </xsl:if>
</xsl:template>

<!-- *** space_normalized_query: q = /GSP/Q *** -->
<xsl:variable name="qval">
  <xsl:value-of select="/GSP/Q"/>
</xsl:variable>

<xsl:variable name="space_normalized_query">
  <xsl:value-of select="normalize-space($qval)"
    disable-output-escaping="yes"/>
</xsl:variable>

<!-- *** stripped_search_query: q, as_q, ... for cache highlight *** -->
<xsl:variable name="stripped_search_query"><xsl:for-each
  select="/GSP/PARAM[(@name = 'q') or
                     (@name = 'as_q') or
                     (@name = 'as_oq') or
                     (@name = 'as_epq')]"><xsl:value-of select="@original_value"
  /><xsl:if test="position() != last()"
    ><xsl:text disable-output-escaping="yes">+</xsl:text
     ></xsl:if></xsl:for-each>
</xsl:variable>

<xsl:variable name="access">
  <xsl:choose>
    <xsl:when test="/GSP/PARAM[(@name='access') and ((@value='s') or (@value='a'))]">
      <xsl:value-of select="/GSP/PARAM[@name='access']/@original_value"/>
    </xsl:when>
    <xsl:otherwise>p</xsl:otherwise>
  </xsl:choose>
</xsl:variable>

<!-- **********************************************************************
 Figure out what kind of page this is (do not customize)
     ********************************************************************** -->
<xsl:template match="GSP">
  <xsl:choose>
    <xsl:when test="Q">
      <xsl:choose>
        <xsl:when test="$swrnum != 0">
          <xsl:call-template name="swr_search"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:call-template name="search_results"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:when>
    <xsl:when test="CACHE">
      <xsl:call-template name="cached_page"/>
    </xsl:when>
    <xsl:when test="CUSTOM/HOME">
      <xsl:call-template name="front_door"/>
    </xsl:when>
    <xsl:when test="ERROR">
      <xsl:call-template name="error_page">
        <xsl:with-param name="errorMessage" select="$server_error_msg_text"/>
        <xsl:with-param name="errorDescription" select="$server_error_des_text"/>
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <xsl:call-template name="error_page">
        <xsl:with-param name="errorMessage" select="$xml_error_msg_text"/>
        <xsl:with-param name="errorDescription" select="$xml_error_des_text"/>
      </xsl:call-template>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<!-- **********************************************************************
 Cached page (do not customize)
     ********************************************************************** -->
<xsl:template name="cached_page">
<xsl:variable name="cached_page_url" select="CACHE/CACHE_URL"/>
<xsl:variable name="cached_page_html" select="CACHE/CACHE_HTML"/>

<!-- *** decide whether to load html page or pdf file *** -->
<xsl:if test="'.pdf' != substring($cached_page_url,
              1 + string-length($cached_page_url) - string-length('.pdf')) and
              not(starts-with($cached_page_url, $db_url_protocol)) and
              not(starts-with($cached_page_url, $smb_url_protocol)) and
              not(starts-with($cached_page_url, $nfs_url_protocol))">
    <base href="{$cached_page_url}"/>
</xsl:if>

<!-- *** display cache page header *** -->
<xsl:call-template name="cached_page_header">
  <xsl:with-param name="cached_page_url" select="$cached_page_url"/>
</xsl:call-template>

<!-- *** display cached contents *** -->
<xsl:value-of select="$cached_page_html" disable-output-escaping="yes"/>
</xsl:template>


<!-- **********************************************************************
 Resend query with filter=p to disable path_filtering
 if there is only one result cluster (do not customize)
     ********************************************************************** -->
<xsl:template name="redirect_if_few_results">
  <xsl:variable name="count" select="count(/GSP/RES/R)"/>
  <xsl:variable name="start" select="/GSP/RES/@SN"/>
  <xsl:variable name="filterall"
    select="count(/GSP/PARAM[@name='filter']) = 0"/>
  <xsl:variable name="filter" select="/GSP/PARAM[@name='filter']/@value"/>

</xsl:template>

<!-- **********************************************************************
 Search results (do not customize)
     ********************************************************************** -->
<xsl:template name="search_results">
<xsl:call-template name="htmlStart"/>

  <!-- *** HTML header and style *** -->
  <xsl:call-template name="langHeadStart"/>
    <xsl:call-template name="redirect_if_few_results"/>
<title><xsl:value-of select="$result_page_title"/>: <xsl:value-of select="$space_normalized_query"/></title>
    <xsl:call-template name="style"/>
  <xsl:call-template name="langHeadEnd"/>

<body>

  <!-- *** Customer's own result page header *** -->
  <xsl:if test="$choose_result_page_header = 'mine' or
                $choose_result_page_header = 'both'">
    <xsl:call-template name="my_page_header"/>
  </xsl:if>

  <!-- *** Result page header *** -->
  <xsl:if test="$choose_result_page_header = 'provided' or
                $choose_result_page_header = 'both'">
    <xsl:call-template name="result_page_header" />
  </xsl:if>

  <!-- *** Handle spelling suggestions, if any *** -->
  <xsl:if test="$show_spelling != '0'">
    <xsl:call-template name="spelling"/>
  </xsl:if>
  
  <!-- *** Handle OneBox results, if any ***-->
  <xsl:if test="$show_onebox != '0'">
    <xsl:if test="/GSP/ENTOBRESULTS">
      <xsl:call-template name="onebox"/>
    </xsl:if>
  </xsl:if>

  <!-- *** Top separation bar *** -->
  <xsl:if test="Q != ''">
    <xsl:call-template name="top_sep_bar">
      <xsl:with-param name="text" select="$sep_bar_std_text"/>
        <xsl:with-param name="show_info" select="$show_search_info"/>
      <xsl:with-param name="time" select="TM"/>
    </xsl:call-template>
  </xsl:if>

  <!-- Handle keymatch results, if any -->
  <xsl:if test="$show_keymatch != '0' and count(/GSP/GM)>0">
    <p>
      <strong><xsl:value-of select="$keymatch_text"/>:</strong><br />
      <xsl:apply-templates select="/GSP/GM"/>
    </p>
  </xsl:if>

    <!-- *** Handle results (if any) *** -->
    <xsl:choose>
      <xsl:when test="RES or GM or Spelling or Synonyms or CT">
        <xsl:call-template name="results">
          <xsl:with-param name="query" select="Q"/>
          <xsl:with-param name="time" select="TM"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="Q=''">
      </xsl:when>
      <xsl:otherwise>
        <xsl:call-template name="no_RES">
          <xsl:with-param name="query" select="Q"/>
        </xsl:call-template>
      </xsl:otherwise>
    </xsl:choose>

    <!-- *** Google footer *** -->
    <xsl:call-template name="copyright"/>

    <!-- *** Customer's own result page footer *** -->
    <xsl:call-template name="my_page_footer"/>

  <!-- *** HTML footer *** -->
</body>
<xsl:call-template name="htmlEnd"/>

</xsl:template>


<!-- **********************************************************************
  Collection menu beside the search box
     ********************************************************************** -->
<xsl:template name="collection_menu">
  <xsl:if test="$search_collections_xslt != ''">
        
<select name="site">
 <xsl:choose>
  <xsl:when test="PARAM[(@name='site') and (@value='default_collection')]">
   <option value="default_collection" selected="selected">default_collection</option>
  </xsl:when>
  <xsl:otherwise>
   <option value="default_collection">default_collection</option>
  </xsl:otherwise>
 </xsl:choose>
 <xsl:choose>
  <xsl:when test="PARAM[(@name='site') and (@value='googleenterprise')]">
   <option value="googleenterprise" selected="selected">googleenterprise</option>
  </xsl:when>
  <xsl:otherwise>
   <option value="googleenterprise">googleenterprise</option>
  </xsl:otherwise>
 </xsl:choose>
</select>
    <br />
  </xsl:if>
</xsl:template>

<!-- **********************************************************************
  Search box input form (Types: std_top, std_bottom, home, swr)
     ********************************************************************** -->
<xsl:template name="search_box">
  <xsl:param name="type"/>

  <form method="get" action="search">
	<fieldset>
	  <xsl:if test="($type = 'swr')">
        <div>There were about <strong><xsl:value-of select="RES/M"/></strong> results for <strong><xsl:value-of select="$space_normalized_query"/></strong>. Search within these results.</div>
      </xsl:if>

      <xsl:choose>
        <xsl:when test="($type = 'swr')"><input type="text" name="as_q" size="{$search_box_size}" maxlength="256" value=""/>
<input type="hidden" name="q" value="{$qval}"/></xsl:when>
        <xsl:otherwise><input type="text" name="q" size="{$search_box_size}" maxlength="256" value="{$space_normalized_query}"/></xsl:otherwise>
      </xsl:choose>
      <br />

      <xsl:call-template name="collection_menu"/>

      <xsl:choose>
        <xsl:when test="$choose_search_button = 'image'">
          <input type="image" name="btnG" src="{$search_button_image_url}"
                 valign="bottom" width="60" height="26"
                 border="0" value="{$search_button_text}"/>
        </xsl:when>
        <xsl:otherwise>
          <input type="submit" name="btnG" value="{$search_button_text}"/>
        </xsl:otherwise>
      </xsl:choose>
      <br />

      <xsl:if test="$show_secure_radio != '0'">
        <xsl:choose>
          <xsl:when test="$access='p'"><input type="radio" name="access" value="p" checked="checked" />Public Content</xsl:when>
          <xsl:otherwise><input type="radio" name="access" value="p"/>Public Content</xsl:otherwise>
        </xsl:choose>
        <br />
        <xsl:choose>
          <xsl:when test="$access='a'"><input type="radio" name="access" value="a" checked="checked" />Public and Secure Content</xsl:when>
          <xsl:otherwise><input type="radio" name="access" value="a"/>Public and Secure Content</xsl:otherwise>
        </xsl:choose>
      </xsl:if>

      <xsl:call-template name="form_params"/>
    </fieldset>
  </form>
</xsl:template>


<!-- **********************************************************************
  Bottom search box (do not customized)
     ********************************************************************** -->
<xsl:template name="bottom_search_box">
  <xsl:call-template name="search_box">
    <xsl:with-param name="type" select="'std_bottom'"/>
  </xsl:call-template>
</xsl:template>


<!-- **********************************************************************
 Sort-by criteria: sort by date/relevance
     ********************************************************************** -->
<xsl:template name="sort_by">
  <xsl:variable name="sort_by_url"><xsl:for-each
    select="/GSP/PARAM[(@name != 'sort') and
                       (@name != 'start') and
                       (@name != 'epoch' or $is_test_search != '') and
                       not(starts-with(@name, 'metabased_'))]">
      <xsl:value-of select="@name"/><xsl:text>=</xsl:text>
      <xsl:value-of select="@original_value"/>
      <xsl:if test="position() != last()">
        <xsl:text disable-output-escaping="yes">&amp;</xsl:text>
      </xsl:if>
    </xsl:for-each>
  </xsl:variable>

  <xsl:variable name="sort_by_relevance_url">
    <xsl:value-of select="$sort_by_url"
      />&amp;sort=date%3AD%3AL%3Ad1</xsl:variable>

  <xsl:variable name="sort_by_date_url">
    <xsl:value-of select="$sort_by_url"
      />&amp;sort=date%3AD%3AS%3Ad1</xsl:variable>

  <div class="s">
  <xsl:choose>
    <xsl:when test="/GSP/PARAM[@name = 'sort' and starts-with(@value,'date:D:S')]">
      <span class="gt">
      <xsl:text>Sort by date / </xsl:text>
      </span>
      <a href="search?{$sort_by_relevance_url}">Sort by relevance</a>
    </xsl:when>
    <xsl:when test="/GSP/PARAM[@name = 'sort' and starts-with(@value,'date:A:S')]">
      <span class="gt">
      <xsl:text>Sort by date / </xsl:text>
      </span>
      <a href="search?{$sort_by_relevance_url}">Sort by relevance</a>
    </xsl:when>
    <xsl:otherwise>
      <a href="search?{$sort_by_date_url}">Sort by date</a>
      <span class="gt">
      <xsl:text> / Sort by relevance</xsl:text>
      </span>
    </xsl:otherwise>
  </xsl:choose>
  </div>
</xsl:template>

<!-- **********************************************************************
 Output all results
     ********************************************************************** -->
<xsl:template name="results">
  <xsl:param name="query"/>
  <xsl:param name="time"/>

  <!-- *** Handle synonyms, if any *** -->
    <xsl:if test="$show_synonyms != '0'">
      <xsl:call-template name="synonyms"/>
    </xsl:if>
		
	  <!-- *** Add top navigation/sort-by bar *** -->
	  <xsl:if test="count(/GSP/RES/R)>0 and (($show_top_navigation != '0') or ($show_sort_by != '0'))">
	    <xsl:if test="$show_top_navigation != '0'">
	        <xsl:call-template name="google_navigation">
	          <xsl:with-param name="prev" select="RES/NB/PU"/>
	          <xsl:with-param name="next" select="RES/NB/NU"/>
	          <xsl:with-param name="view_begin" select="RES/@SN"/>
	          <xsl:with-param name="view_end" select="RES/@EN"/>
	          <xsl:with-param name="guess" select="RES/M"/>
	          <xsl:with-param name="navigation_style" select="'top'"/>
	        </xsl:call-template>
	        <br />
	    </xsl:if>
	    <xsl:if test="$show_sort_by != '0'">
	      <xsl:call-template name="sort_by"/>
	    </xsl:if>
	  </xsl:if>
	
  <!-- *** Output results details *** -->

    <xsl:if test="count(RES/R)>0 or ((RES/FI) and (not(RES/NB/NU)))">
    <div>
    <!-- for real results -->
    <xsl:apply-templates select="RES/R">
      <xsl:with-param name="query" select="$query"/>
    </xsl:apply-templates>

  <!-- *** Filter note (if needed) *** -->
    <xsl:if test="(RES/FI) and (not(RES/NB/NU))">
      <p>
        <em>
        In order to show you the most relevant results,    we have omitted some entries very similar to the <xsl:value-of select="RES/@EN"/> already    displayed.
        </em>
      </p>
      <p>
	    <em>
		If you like, you can <a href="{$filter_url}0">    repeat the search with the omitted results included</a>.
        </em>
      </p>
    </xsl:if>
    </div>
    </xsl:if>

  <!-- *** Add bottom navigation *** -->
    <xsl:variable name="nav_style">
      <xsl:choose>
        <xsl:when test="($access='s') or ($access='a')">simple</xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="$choose_bottom_navigation"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>

    <xsl:call-template name="google_navigation">
      <xsl:with-param name="prev" select="RES/NB/PU"/>
      <xsl:with-param name="next" select="RES/NB/NU"/>
      <xsl:with-param name="view_begin" select="RES/@SN"/>
      <xsl:with-param name="view_end" select="RES/@EN"/>
      <xsl:with-param name="guess" select="RES/M"/>
      <xsl:with-param name="navigation_style" select="$nav_style"/>
    </xsl:call-template>

  <xsl:if test="count(/GSP/RES/R)>0 "><hr /></xsl:if>

  <!-- *** Bottom search box *** -->
    <xsl:if test="$show_bottom_search_box != '0'">
      <xsl:call-template name="bottom_search_box"/>
    </xsl:if>

</xsl:template>


<!-- **********************************************************************
 Stopwords suggestions in result page (do not customize)
     ********************************************************************** -->
<xsl:template name="stopwords">
  <xsl:variable name="stopwords_suggestions1">
    <xsl:call-template name="replace_string">
      <xsl:with-param name="find" select="'/help/basics.html#stopwords'"/>
      <xsl:with-param name="replace" select="'user_help.html#stop'"/>
      <xsl:with-param name="string" select="/GSP/CT"/>
    </xsl:call-template>
  </xsl:variable>

  <xsl:variable name="stopwords_suggestions">
    <xsl:call-template name="replace_string">
      <xsl:with-param name="find" select="'/help/basics.html'"/>
      <xsl:with-param name="replace" select="'user_help.html'"/>
      <xsl:with-param name="string" select="$stopwords_suggestions1"/>
    </xsl:call-template>
  </xsl:variable>

  <xsl:if test="/GSP/CT">
    <div class="sw">
      <xsl:value-of disable-output-escaping="yes"
        select="$stopwords_suggestions"/>
    </div>
  </xsl:if>
</xsl:template>


<!-- **********************************************************************
 Spelling suggestions in result page (do not customize)
     ********************************************************************** -->
<xsl:template name="spelling">
  <xsl:if test="/GSP/Spelling/Suggestion">
    <p><span class="p sp">
         <xsl:value-of select="$spelling_text"/>
         <xsl:call-template name="nbsp"/>
       </span>
       <a href="search?q={/GSP/Spelling/Suggestion[1]/@qe}&amp;spell=1&amp;{$base_url}">
	   <xsl:variable name="suggestion">
	     <xsl:call-template name="reformat_semantic">
	       <xsl:with-param name="markup" select="/GSP/Spelling/Suggestion[1]"/>
	     </xsl:call-template>
	   </xsl:variable>
       <xsl:value-of disable-output-escaping="yes" select="$suggestion"/>
      </a>
    </p>
    <!-- <hr /> -->
  </xsl:if>
</xsl:template>


<!-- **********************************************************************
 Synonym suggestions in result page (do not customize)
     ********************************************************************** -->
<xsl:template name="synonyms">
  <xsl:if test="/GSP/Synonyms/OneSynonym">
    <p><span class="p sy">
         <xsl:value-of select="$synonyms_text"/>
         <xsl:call-template name="nbsp"/>
       </span>
    <xsl:for-each select="/GSP/Synonyms/OneSynonym">
      <a href="search?q={@q}&amp;{$synonym_url}">
        <xsl:value-of disable-output-escaping="yes" select="."/>
      </a><xsl:text> </xsl:text>
    </xsl:for-each>
    </p>
  </xsl:if>
</xsl:template>


<!-- **********************************************************************
 Truncation functions (do not customize)
     ********************************************************************** -->
<xsl:template name="truncate_url">
  <xsl:param name="t_url"/>

  <xsl:choose>
    <xsl:when test="string-length($t_url) &lt; $truncate_result_url_length">
      <xsl:value-of select="$t_url"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:variable name="first" select="substring-before($t_url, '/')"/>
      <xsl:variable name="last">
              <xsl:call-template name="truncate_find_last_token">
                <xsl:with-param name="t_url" select="$t_url"/>
              </xsl:call-template>
      </xsl:variable>
      <xsl:variable name="path_limit" select="$truncate_result_url_length - (string-length($first) + string-length($last) + 1)"/>

      <xsl:choose>
              <xsl:when test="$path_limit &lt;= 0">
                <xsl:value-of select="concat(substring($t_url, 1, $truncate_result_url_length), '...')"/>
              </xsl:when>
              <xsl:otherwise>
                <xsl:variable name="chopped_path">
                  <xsl:call-template name="truncate_chop_path">
                    <xsl:with-param name="path" select="substring($t_url, string-length($first) + 2, string-length($t_url) - (string-length($first) + string-length($last) + 1))"/>
                    <xsl:with-param name="path_limit" select="$path_limit"/>
                  </xsl:call-template>
                </xsl:variable>
                <xsl:value-of select="concat($first, '/.../', $chopped_path, $last)"/>
              </xsl:otherwise>
      </xsl:choose>
    </xsl:otherwise>
  </xsl:choose>

</xsl:template>

<xsl:template name="truncate_find_last_token">
  <xsl:param name="t_url"/>

  <xsl:choose>
    <xsl:when test="contains($t_url, '/')">
      <xsl:call-template name="truncate_find_last_token">
            <xsl:with-param name="t_url" select="substring-after($t_url, '/')"/>
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
            <xsl:value-of select="$t_url"/>
    </xsl:otherwise>
  </xsl:choose>

</xsl:template>

<xsl:template name="truncate_chop_path">
  <xsl:param name="path"/>
  <xsl:param name="path_limit"/>

  <xsl:choose>
    <xsl:when test="string-length($path) &lt;= $path_limit">
      <xsl:value-of select="$path"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:call-template name="truncate_chop_path">
        <xsl:with-param name="path" select="substring-after($path, '/')"/>
        <xsl:with-param name="path_limit" select="$path_limit"/>
      </xsl:call-template>
    </xsl:otherwise>
  </xsl:choose>

</xsl:template>

<xsl:template name="truncate_at_word">
  <xsl:param name="text"/>
  <xsl:param name="limit"/>

  <xsl:choose>
    <xsl:when test="string-length($text) &lt;= $limit">
      <xsl:value-of select="$text"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="concat(substring($text, 1, $limit), substring-before(substring($text, $limit+1), ' '))"/>
    </xsl:otherwise>
  </xsl:choose>

</xsl:template>

<!-- **********************************************************************
  A single result (do not customize)
     ********************************************************************** -->
<xsl:template match="R">
  <xsl:param name="query"/>

  <xsl:variable name="display_url_tmp" select="substring-after(UD, '://')"/>
  <xsl:variable name="display_url">
    <xsl:choose>
      <xsl:when test="$display_url_tmp">
        <xsl:value-of select="$display_url_tmp"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="substring-after(U, '://')"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>
  <xsl:variable name="escaped_url" select="substring-after(UE, '://')"/>
  <xsl:variable name="protocol" select="substring-before(U, '://')"/>
  <xsl:variable name="full_url" select="UE"/>
  <xsl:variable name="crowded_url" select="HN/@U"/>
  <xsl:variable name="crowded_display_url" select="HN"/>
  <xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/>
  <xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>

  <xsl:variable name="temp_url" select="substring-after(U, '://')"/>
  <xsl:variable name="url_indexed" select="not(starts-with($temp_url, 'noindex!/'))"/>
  <xsl:variable name="stripped_url">
    <xsl:choose>
      <xsl:when test="$truncate_result_urls != '0'">
        <xsl:call-template name="truncate_url">
          <xsl:with-param name="t_url" select="$display_url"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$display_url"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>
  <xsl:variable name="result_num" select="(@N)-(/GSP/RES/@SN)+1"/>

  <!-- *** Result Header *** -->
  <p class="g">

  <!-- *** Result Number *** -->
  <strong><xsl:value-of select="$result_num"/></strong>
  <xsl:text> </xsl:text>

  <!-- *** Result Title (including PDF tag and hyperlink) *** -->
  <xsl:if test="$show_res_title != '0'">
    <xsl:choose>
      <xsl:when test="@MIME='text/html' or @MIME='' or not(@MIME)"></xsl:when>
      <xsl:when test="@MIME='text/plain'">[TEXT]</xsl:when>
      <xsl:when test="@MIME='application/rtf'">[RTF]</xsl:when>
      <xsl:when test="@MIME='application/pdf'">[PDF]</xsl:when>
      <xsl:when test="@MIME='application/postscript'">[PS]</xsl:when>
      <xsl:when test="@MIME='application/vnd.ms-powerpoint'">[MS POWERPOINT]</xsl:when>
      <xsl:when test="@MIME='application/vnd.ms-excel'">[MS EXCEL]</xsl:when>
      <xsl:when test="@MIME='application/msword'">[MS WORD]</xsl:when>
      <xsl:otherwise>
        <xsl:variable name="extension">
          <xsl:call-template name="last_substring_after">
            <xsl:with-param name="string" select="substring-after(
                                                  substring-after(U,'://'),
                                                  '/')"/>
            <xsl:with-param name="separator" select="'.'"/>
            <xsl:with-param name="fallback" select="'UNKNOWN'"/>
          </xsl:call-template>
        </xsl:variable>
        [<xsl:value-of select="translate($extension,$lower,$upper)"/>]
      </xsl:otherwise>
    </xsl:choose>
    <xsl:text> </xsl:text>

    <xsl:if test="$url_indexed">

      <xsl:text disable-output-escaping='yes'>&lt;a href="</xsl:text>

      <xsl:choose>
	<!-- *** URI for smb or NFS must be escaped because it appears in the URI query *** -->
        <xsl:when test="$protocol='smb' or $protocol='nfs'">
	      <xsl:value-of disable-output-escaping='yes'
	                    select="concat($protocol,'/',
                                substring-after(U,'://'))"/>
        </xsl:when>
        <xsl:when test="starts-with(U, $db_url_protocol)">
          <xsl:value-of disable-output-escaping='yes'
                        select="concat('db/',
                                substring-after(U,'://'))"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of disable-output-escaping='yes' select="U"/>
        </xsl:otherwise>
      </xsl:choose>
      <xsl:text disable-output-escaping='yes'>" accesskey="</xsl:text>
      <xsl:value-of select="$result_num mod $num_results"/>
	  <xsl:text disable-output-escaping='yes'>"&gt;</xsl:text>
    </xsl:if>
    <span class="l">
    <xsl:choose>
      <xsl:when test="T">
        <xsl:call-template name="reformat_keyword">
          <xsl:with-param name="orig_string" select="T"/>
          <xsl:with-param name="type" select="'title'"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise><xsl:value-of select="$stripped_url"/></xsl:otherwise>
    </xsl:choose>
    </span>
    <xsl:if test="$url_indexed">
        <xsl:text disable-output-escaping='yes'>&lt;/a&gt;</xsl:text>
    </xsl:if>
  </xsl:if>

  <!-- *** Snippet Box *** -->
  <span class="s">
    <xsl:if test="$show_res_snippet != '0'">
	  <xsl:call-template name="nbsp"/>- <xsl:call-template name="reformat_keyword">
        <xsl:with-param name="orig_string" select="S"/>
        <xsl:with-param name="type" select="'snippet'"/>
      </xsl:call-template>
    </xsl:if>

    <!-- *** Meta tags *** -->
    <xsl:if test="$show_meta_tags != '0'">
      <xsl:apply-templates select="MT"/>
    </xsl:if>

    <!-- *** URL *** -->
    <xsl:call-template name="nbsp"/>- <span class="url">
      <xsl:choose>
        <xsl:when test="not($url_indexed)">
          <xsl:if test="($show_res_size!='0') or
                        ($show_res_date!='0') or
                        ($show_res_cache!='0')">
            <xsl:text>Not Indexed:</xsl:text>
            <xsl:value-of select="$stripped_url"/>
          </xsl:if>
        </xsl:when>
        <xsl:otherwise>
          <xsl:if test="$show_res_url != '0'">
            <xsl:value-of select="$stripped_url"/>
          </xsl:if>
        </xsl:otherwise>
      </xsl:choose>
    </span>

    <!-- *** Miscellaneous (- size - date - cache) *** -->
    <xsl:if test="$url_indexed">
      <xsl:apply-templates select="HAS/C">
        <xsl:with-param name="stripped_url" select="$stripped_url"/>
        <xsl:with-param name="escaped_url" select="$escaped_url"/>
        <xsl:with-param name="query" select="$query"/>
        <xsl:with-param name="mime" select="@MIME"/>
        <xsl:with-param name="date" select="FS[@NAME='date']/@VALUE"/>
      </xsl:apply-templates>
    </xsl:if>

    <!-- *** Link to more links from this site *** -->
    <xsl:if test="HN">
      <br/> [ <a class="f" href="search?as_sitesearch={$crowded_url}&amp;{
        $search_url}">More results from <xsl:value-of select="$crowded_display_url"/></a> ]<!-- (DO NOT DELETE: formatting workaround)
-->
      <!-- *** Link to aggregated results from database source *** -->
      <xsl:if test="starts-with($crowded_url, $db_url_protocol)">
        [ <a class="f" href="dbaggr?sitesearch={$crowded_url}&amp;{
          $search_url}">View all data</a> ]
      </xsl:if>
    </xsl:if>

  <!-- *** Result Footer *** -->
</span></p>

</xsl:template>

<!-- **********************************************************************
  Meta tag values within a result (do not customize)
     ********************************************************************** -->
<xsl:template match="MT">
  <br/>
  <span class="f"><xsl:value-of select="@N"/>: </span><xsl:value-of select="@V"/>
</xsl:template>

<!-- **********************************************************************
  A single keymatch result (do not customize)
     ********************************************************************** -->
<xsl:template match="GM">
  <xsl:variable name="gl_trim">
	<xsl:call-template name="replace_string">
      <xsl:with-param name="find" select="'http://'"/>
      <xsl:with-param name="replace" select="''"/>
      <xsl:with-param name="string" select="GL"/>
    </xsl:call-template>
  </xsl:variable>
  <a href="{GL}"><xsl:value-of select="GD"/></a> - <span class="url"><xsl:value-of select="$gl_trim"/></span><br />
</xsl:template>


<!-- **********************************************************************
  Variables for reformatting keyword-match display (do not customize)
     ********************************************************************** -->
<xsl:variable name="keyword_orig_start" select="'&lt;b&gt;'"/>
<xsl:variable name="keyword_orig_end" select="'&lt;/b&gt;'"/>

<xsl:variable name="keyword_reformat_start">
  <xsl:if test="$res_keyword_format">
    <xsl:text>&lt;</xsl:text>
    <xsl:value-of select="$res_keyword_format"/>
    <xsl:text>&gt;</xsl:text>
  </xsl:if>
  <xsl:if test="($res_keyword_size) or ($res_keyword_color)">
  <xsl:text>&lt;font</xsl:text>
  <xsl:if test="$res_keyword_size">
    <xsl:text> size="</xsl:text>
    <xsl:value-of select="$res_keyword_size"/>
    <xsl:text>"</xsl:text>
  </xsl:if>
  <xsl:if test="$res_keyword_color">
    <xsl:text> color="</xsl:text>
    <xsl:value-of select="$res_keyword_color"/>
    <xsl:text>"</xsl:text>
  </xsl:if>
  <xsl:text>&gt;</xsl:text>
  </xsl:if>
</xsl:variable>

<xsl:variable name="keyword_reformat_end">
  <xsl:if test="($res_keyword_size) or ($res_keyword_color)">
    <xsl:text>&lt;/font&gt;</xsl:text>
  </xsl:if>
  <xsl:if test="$res_keyword_format">
    <xsl:text>&lt;/</xsl:text>
    <xsl:value-of select="$res_keyword_format"/>
    <xsl:text>&gt;</xsl:text>
  </xsl:if>
</xsl:variable>

<!-- **********************************************************************
  Reformat the keyword match display in a title/snippet string
     (do not customize)
     ********************************************************************** -->
<xsl:template name="reformat_keyword">
  <xsl:param name="orig_string"/>
  <xsl:param name="type"/>

  <xsl:variable name="reformatted_1">
    <xsl:call-template name="replace_string">
      <xsl:with-param name="find" select="$keyword_orig_start"/>
      <xsl:with-param name="replace" select="$keyword_reformat_start"/>
      <xsl:with-param name="string" select="$orig_string"/>
    </xsl:call-template>
  </xsl:variable>

  <xsl:variable name="reformatted_2">
    <xsl:call-template name="replace_string">
      <xsl:with-param name="find" select="$keyword_orig_end"/>
      <xsl:with-param name="replace" select="$keyword_reformat_end"/>
      <xsl:with-param name="string" select="$reformatted_1"/>
    </xsl:call-template>
  </xsl:variable>

  <!-- Ensure br is well formed (or removed for mobile output). -->
  <xsl:variable name="br_html">&lt;br&gt;</xsl:variable>
  <xsl:variable name="br_xhtml"> </xsl:variable>
  <xsl:variable name="reformatted_3">
    <xsl:call-template name="replace_string">
      <xsl:with-param name="find" select="$br_html"/>
      <xsl:with-param name="replace" select="$br_xhtml"/>
      <xsl:with-param name="string" select="$reformatted_2"/>
    </xsl:call-template>
  </xsl:variable>

  <xsl:variable name="reformatted_4">
    <xsl:choose>
      <xsl:when test="$type = 'snippet'">
        <xsl:call-template name="truncate_at_word">
          <xsl:with-param name="text" select="$reformatted_3"/>
          <xsl:with-param name="limit" select="$truncate_result_snippet_length"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="$type = 'title'">
        <xsl:choose>
          <xsl:when test="string-length($reformatted_3) &gt; $truncate_result_title_length">
            <xsl:value-of select="concat(substring($reformatted_3, 1, $truncate_result_title_length), '...')"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="$reformatted_3"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:when>
      <xsl:otherwise>
        <!-- Actually, we should never end up here. :) -->
      	<xsl:value-of select="$reformatted_3"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>
	
  <xsl:value-of disable-output-escaping='yes' select="$reformatted_4"/>

</xsl:template>


<!-- **********************************************************************
	  Helper templates for converting standard-issue HTML elements
	  to more semantic variants (do not customize) ********************************************************************** -->
<xsl:template name="reformat_semantic">
  <xsl:param name="markup"/>

  <!-- List of elements we'll be replacing (keep space at the end) -->
  <xsl:param name="from" select="'b i '"/>
  <xsl:param name="to" select="'strong em '"/>

  <!-- Get the next pair of search/replace candidates -->
  <xsl:variable name="find" select="substring-before($from, ' ')"/>
  <xsl:variable name="replace" select="substring-before($to, ' ')"/>

  <xsl:choose>
    <xsl:when test="$find">
      <xsl:variable name="markup-new-2">
        <xsl:call-template name="replace_string">
          <xsl:with-param name="find" select="concat('&lt;',$find,'&gt;')"/>
          <xsl:with-param name="replace" select="concat('&lt;',$replace,'&gt;')"/>
          <xsl:with-param name="string" select="$markup"/>
        </xsl:call-template>
      </xsl:variable>
      <xsl:variable name="markup-new">
        <xsl:call-template name="replace_string">
          <xsl:with-param name="find" select="concat('&lt;/',$find,'&gt;')"/>
          <xsl:with-param name="replace" select="concat('&lt;/',$replace,'&gt;')"/>
          <xsl:with-param name="string" select="$markup-new-2"/>
        </xsl:call-template>
      </xsl:variable>
      <!-- Recursion: It's fun for the whole family! -->
      <xsl:call-template name="reformat_semantic">
        <xsl:with-param name="markup" select="$markup-new"/>
        <xsl:with-param name="from" select="substring-after($from, ' ')"/>
        <xsl:with-param name="to" select="substring-after($to, ' ')"/>
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$markup"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<!-- **********************************************************************
  Helper templates for generating a result item (do not customize)
     ********************************************************************** -->

<!-- *** Miscellaneous: - size - date - cache *** -->
<xsl:template match="C">
    <xsl:param name="stripped_url"/>
    <xsl:param name="escaped_url"/>
    <xsl:param name="query"/>
    <xsl:param name="mime"/>
    <xsl:param name="date"/>

    <xsl:variable name="docid"><xsl:value-of select="@CID"/></xsl:variable>

    <xsl:if test="$show_res_size != '0'">
    <xsl:if test="not(@SZ='')">
        <span class="url">
          <xsl:text> - </xsl:text>
          <xsl:value-of select="@SZ"/>
        </span>
    </xsl:if>
    </xsl:if>

    <xsl:if test="$show_res_date != '0'">
    <xsl:if test="($date != '') and
                  (translate($date, '-', '') &gt; 19500000) and
                  (translate($date, '-', '') &lt; 21000000)">
        <span class="url">
        <xsl:text> - </xsl:text>
        <xsl:value-of select="$date"/>
        </span>
    </xsl:if>
    </xsl:if>

    <xsl:if test="$show_res_cache != '0'">
        <span class="url">
        <xsl:text> - </xsl:text>
        </span>
        <xsl:variable name="cache_encoding">
          <xsl:choose>
            <xsl:when test="'' != @ENC"><xsl:value-of select="@ENC"/></xsl:when>
            <xsl:otherwise>UTF-8</xsl:otherwise>
          </xsl:choose>
        </xsl:variable>
        <a class="f" href="search?q=cache:{$docid}:{$escaped_url}+{
                           $stripped_search_query}&amp;{$base_url}&amp;oe={
                           $cache_encoding}">
          <xsl:choose>
            <xsl:when test="not($mime)">Cached</xsl:when>
            <xsl:when test="$mime='text/html'">Cached</xsl:when>
            <xsl:when test="$mime='text/plain'">Cached</xsl:when>
            <xsl:otherwise>Text Version</xsl:otherwise>
          </xsl:choose>
        </a>
    </xsl:if>

</xsl:template>


<!-- **********************************************************************
 Google navigation bar in result page (do not customize)
     ********************************************************************** -->
<xsl:template name="google_navigation">
    <xsl:param name="prev"/>
    <xsl:param name="next"/>
    <xsl:param name="view_begin"/>
    <xsl:param name="view_end"/>
    <xsl:param name="guess"/>
    <xsl:param name="navigation_style"/>

  <xsl:variable name="fontclass">
    <xsl:choose>
      <xsl:when test="$navigation_style = 'top'">s</xsl:when>
      <xsl:otherwise>b</xsl:otherwise>
    </xsl:choose>
  </xsl:variable>

  <!-- *** Test to see if we should even show navigation *** -->
  <xsl:if test="($prev) or ($next)">

  <!-- *** Start Google result navigation bar *** -->
  <div>

  <!-- *** Show previous navigation, if available *** -->
        <xsl:choose>
          <xsl:when test="$prev">
              <span class="{$fontclass}">
              <a href="search?{$search_url}&amp;start={$view_begin -
                      $num_results - 1}">
                <xsl:if test="$navigation_style = 'google'">

                  <img src="/nav_previous.gif" width="68" height="26"
                    alt="Previous" border="0"/>
                  <br/>
                 </xsl:if>
                <xsl:if test="$navigation_style = 'top'">
                  <xsl:text>&lt;</xsl:text>
                </xsl:if>
                <xsl:text>Prev</xsl:text>
              </a>
              </span>
              <xsl:if test="$navigation_style != 'google'">
                  <xsl:call-template name="nbsp"/>
              </xsl:if>
          </xsl:when>
          <xsl:otherwise>
              <xsl:if test="$navigation_style = 'google'">
                <img src="/nav_first.gif" width="18" height="26"
                  alt="First" border="0"/>
                <br/>
              </xsl:if>
          </xsl:otherwise>
        </xsl:choose>

        <xsl:if test="($navigation_style = 'google') or
                      ($navigation_style = 'link')">
  <!-- *** Google result set navigation *** -->
        <xsl:variable name="mod_end">
          <xsl:choose>
            <xsl:when test="$next"><xsl:value-of select="$guess"/></xsl:when>
            <xsl:otherwise><xsl:value-of select="$view_end"/></xsl:otherwise>
          </xsl:choose>
        </xsl:variable>
	
        <xsl:call-template name="result_nav">
          <xsl:with-param name="start" select="0"/>
          <xsl:with-param name="end" select="$mod_end"/>
          <xsl:with-param name="current_view" select="($view_begin)-1"/>
          <xsl:with-param name="navigation_style" select="$navigation_style"/>
        </xsl:call-template>
        </xsl:if>

        <xsl:if test="($prev) and ($next) and $navigation_style = 'simple'">|</xsl:if>

  <!-- *** Show next navigation, if available *** -->
        <xsl:choose>
          <xsl:when test="$next">
              <xsl:if test="$navigation_style != 'google'">
                  <xsl:call-template name="nbsp"/>
              </xsl:if>
              <span class="{$fontclass}">
              <a href="search?{$search_url}&amp;start={$view_begin +
                $num_results - 1}">
                <xsl:if test="$navigation_style = 'google'">

                  <img src="/nav_next.gif" width="100" height="26"

                    alt="Next" border="0"/>
                  <br/>
                </xsl:if>
                <xsl:text>Next</xsl:text>
                <xsl:if test="$navigation_style = 'top'">
                  <xsl:text>&gt;</xsl:text>
                </xsl:if>
              </a>
              </span>
          </xsl:when>
          <xsl:otherwise>
              <xsl:if test="$navigation_style != 'google'">
                <xsl:call-template name="nbsp"/>
              </xsl:if>
              <xsl:if test="$navigation_style = 'google'">
                <img src="/nav_last.gif" width="46" height="26"

                  alt="Last" border="0"/>
                <br/>
              </xsl:if>
          </xsl:otherwise>
        </xsl:choose>

  <!-- *** End Google result bar *** -->
  </div>

  </xsl:if>
</xsl:template>

<!-- **********************************************************************
 Helper templates for generating Google result navigation (do not customize)
   only shows 10 sets up or down from current view
     ********************************************************************** -->
<xsl:template name="result_nav">
  <xsl:param name="start" select="'0'"/>
  <xsl:param name="end"/>
  <xsl:param name="current_view"/>
  <xsl:param name="navigation_style"/>

  <!-- *** Choose how to show this result set *** -->
  <xsl:choose>
    <xsl:when test="($start)&lt;(($current_view)-(10*($num_results)))">
    </xsl:when>
    <xsl:when test="(($current_view)&gt;=($start)) and
                    (($current_view)&lt;(($start)+($num_results)))">
      <td>
        <xsl:if test="$navigation_style = 'google'">
          <img src="/nav_current.gif" width="16" height="26" alt="Current"/>
          <br/>
        </xsl:if>
        <xsl:if test="$navigation_style = 'link'">
          <xsl:call-template name="nbsp"/>
        </xsl:if>
        <span class="i"><xsl:value-of
          select="(($start)div($num_results))+1"/></span>
        <xsl:if test="$navigation_style = 'link'">
          <xsl:call-template name="nbsp"/>
        </xsl:if>
      </td>
    </xsl:when>
    <xsl:otherwise>
      <td>
        <xsl:if test="$navigation_style = 'link'">
            <xsl:call-template name="nbsp"/>
        </xsl:if>
        <a href="search?{$search_url}&amp;start={$start}">
        <xsl:if test="$navigation_style = 'google'">
          <img src="/nav_page.gif" width="16" height="26" alt="Navigation"
               border="0"/>
          <br/>
        </xsl:if>
        <xsl:value-of select="(($start)div($num_results))+1"/>
        </a>
        <xsl:if test="$navigation_style = 'link'">
           <xsl:call-template name="nbsp"/>
        </xsl:if>
      </td>
    </xsl:otherwise>
  </xsl:choose>

  <!-- *** Recursively iterate through result sets to display *** -->
  <xsl:if test="((($start)+($num_results))&lt;($end)) and
                ((($start)+($num_results))&lt;(($current_view)+
                (10*($num_results))))">
    <xsl:call-template name="result_nav">
      <xsl:with-param name="start" select="$start+$num_results"/>
      <xsl:with-param name="end" select="$end"/>
      <xsl:with-param name="current_view" select="$current_view"/>
      <xsl:with-param name="navigation_style" select="$navigation_style"/>
    </xsl:call-template>
  </xsl:if>

</xsl:template>


<!-- **********************************************************************
 Top separation bar (do not customize)
     ********************************************************************** -->
<xsl:template name="top_sep_bar">
  <xsl:param name="text"/>
  <xsl:param name="show_info"/>
  <xsl:param name="time"/>

  <xsl:if test="$show_info != '0' and (count(/GSP/RES/R)>0 or $sep_bar_show_time != '0')">
    <div>
    <xsl:if test="count(/GSP/RES/R)>0 ">
	  <strong><xsl:value-of select="$text"/>:</strong>
      <br />'<xsl:value-of select="$space_normalized_query"/>'<br />
      <xsl:choose>
        <xsl:when test="$access = 's' or $access = 'a'">Results <xsl:value-of select="RES/@SN"/> - <xsl:value-of select="RES/@EN"/>. </xsl:when>
        <xsl:otherwise>Results <xsl:value-of select="RES/@SN"/> - <xsl:value-of select="RES/@EN"/> of about <xsl:value-of select="RES/M"/>. </xsl:otherwise>
      </xsl:choose>
    </xsl:if>
    <xsl:if test="$sep_bar_show_time != '0'">Search took <xsl:value-of select="round($time * 100.0) div 100.0"/> seconds.</xsl:if>
    </div>
  </xsl:if>
</xsl:template>

<!-- **********************************************************************
 Utility function for constructing copyright text (do not customize)
     ********************************************************************** -->
<xsl:template name="copyright">
  <p>
	<xsl:if test="not(/GSP/CUSTOM/HOME)">
      <a href="{$home_url}"><xsl:value-of select="$egds_appliance_tab_label"/></a><br />
    </xsl:if>
    <xsl:if test="(/GSP/RES/M > 0) and ($show_swr_link != '0') and ($swrnum = '0')">
      <a href="{$swr_search_url}">
        <xsl:value-of select="$swr_search_anchor_text"/>
      </a>
      <br/>
    </xsl:if>
    <xsl:if test="$show_alerts_link != '0'">
      <a href="{$alerts_url}">
        <xsl:value-of select="$alerts_anchor_text"/>
      </a>
      <br/>
    </xsl:if>
    <xsl:if test="$show_result_page_help_link != '0'">
      <a href="{$help_url}">
        <xsl:value-of select="$search_help_anchor_text"/>
      </a>
      <br/>
    </xsl:if>Powered by Google Search Appliance</p>
</xsl:template>


<!-- **********************************************************************
 Utility functions for generating html entities
     ********************************************************************** -->
<xsl:template name="nbsp">
  <xsl:text disable-output-escaping="yes">&amp;#160;</xsl:text>
</xsl:template>
<xsl:template name="nbsp3">
  <xsl:call-template name="nbsp"/>
  <xsl:call-template name="nbsp"/>
  <xsl:call-template name="nbsp"/>
</xsl:template>
<xsl:template name="nbsp4">
  <xsl:call-template name="nbsp3"/>
  <xsl:call-template name="nbsp"/>
</xsl:template>
<xsl:template name="quot">
  <xsl:text disable-output-escaping="yes">&amp;quot;</xsl:text>
</xsl:template>
<xsl:template name="copy">
  <xsl:text disable-output-escaping="yes">&amp;copy;</xsl:text>
</xsl:template>

<!-- **********************************************************************
 Utility functions for generating head elements so that the XSLT processor
 won't add a meta tag to the output, since it may specify the wrong
 encoding (utf8) in the meta tag.
     ********************************************************************** -->
<xsl:template name="plainHeadStart">
  <xsl:text disable-output-escaping="yes">&lt;head&gt;</xsl:text>
  <meta name="robots" content="noindex,nofollow"/>
  <xsl:text>
  </xsl:text>
</xsl:template>
<xsl:template name="plainHeadEnd">
  <xsl:text disable-output-escaping="yes">&lt;/head&gt;</xsl:text>
  <xsl:text>
  </xsl:text>
</xsl:template>


<!-- **********************************************************************
 Utility functions for generating head elements with a meta tag to the output
 specifying the character set as requested
     ********************************************************************** -->
<xsl:template name="langHeadStart">
  <xsl:text disable-output-escaping="yes">&lt;head&gt;</xsl:text>
  <meta name="robots" content="noindex,nofollow"/>
  <xsl:choose>
    <xsl:when test="PARAM[(@name='oe') and (@value='utf8')]">
      <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8"/>
    </xsl:when>
    <xsl:when test="PARAM[(@name='oe') and (@value!='')]">
      <meta http-equiv="Content-Type" content="application/xhtml+xml; charset={PARAM[@name='oe']/@value}"/>
    </xsl:when>
    <xsl:when test="PARAM[(@name='lr') and (@value='lang_zh-CN')]">
      <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=GB2312"/>
    </xsl:when>
    <xsl:when test="PARAM[(@name='lr') and (@value='lang_zh-TW')]">
      <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=Big5"/>
    </xsl:when>
    <xsl:when test="PARAM[(@name='lr') and (@value='lang_cs')]">
      <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=ISO-8859-2"/>
    </xsl:when>
    <xsl:when test="PARAM[(@name='lr') and (@value='lang_da')]">
      <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=ISO-8859-1"/>
    </xsl:when>
    <xsl:when test="PARAM[(@name='lr') and (@value='lang_nl')]">
      <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=ISO-8859-1"/>
    </xsl:when>
    <xsl:when test="PARAM[(@name='lr') and (@value='lang_en')]">
      <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=ISO-8859-1"/>
    </xsl:when>
    <xsl:when test="PARAM[(@name='lr') and (@value='lang_et')]">
      <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=ISO-8859-1"/>
    </xsl:when>
    <xsl:when test="PARAM[(@name='lr') and (@value='lang_fi')]">
      <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=ISO-8859-1"/>
    </xsl:when>
    <xsl:when test="PARAM[(@name='lr') and (@value='lang_fr')]">
      <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=ISO-8859-1"/>
    </xsl:when>
    <xsl:when test="PARAM[(@name='lr') and (@value='lang_de')]">
      <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=ISO-8859-1"/>
    </xsl:when>
    <xsl:when test="PARAM[(@name='lr') and (@value='lang_el')]">
      <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=ISO-8859-7"/>
    </xsl:when>
    <xsl:when test="PARAM[(@name='lr') and (@value='lang_iw')]">
      <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=ISO-8859-8-I"/>
    </xsl:when>
    <xsl:when test="PARAM[(@name='lr') and (@value='lang_hu')]">
      <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=ISO-8859-2"/>
    </xsl:when>
    <xsl:when test="PARAM[(@name='lr') and (@value='lang_is')]">
      <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=ISO-8859-1"/>
    </xsl:when>
    <xsl:when test="PARAM[(@name='lr') and (@value='lang_it')]">
      <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=ISO-8859-1"/>
    </xsl:when>
    <xsl:when test="PARAM[(@name='lr') and (@value='lang_ja')]">
      <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=Shift_JIS"/>
    </xsl:when>
    <xsl:when test="PARAM[(@name='lr') and (@value='lang_ko')]">
      <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=EUC-KR"/>
    </xsl:when>
    <xsl:when test="PARAM[(@name='lr') and (@value='lang_lv')]">
      <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=ISO-8859-1"/>
    </xsl:when>
    <xsl:when test="PARAM[(@name='lr') and (@value='lang_lt')]">
      <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=ISO-8859-1"/>
    </xsl:when>
    <xsl:when test="PARAM[(@name='lr') and (@value='lang_no')]">
      <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=ISO-8859-1"/>
    </xsl:when>
    <xsl:when test="PARAM[(@name='lr') and (@value='lang_pl')]">
      <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=ISO-8859-2"/>
    </xsl:when>
    <xsl:when test="PARAM[(@name='lr') and (@value='lang_pt')]">
      <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=ISO-8859-1"/>
    </xsl:when>
    <xsl:when test="PARAM[(@name='lr') and (@value='lang_ro')]">
      <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=ISO-8859-2"/>
    </xsl:when>
    <xsl:when test="PARAM[(@name='lr') and (@value='lang_ru')]">
      <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=windows-1251"/>
    </xsl:when>
    <xsl:when test="PARAM[(@name='lr') and (@value='lang_es')]">
      <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=ISO-8859-1"/>
    </xsl:when>
    <xsl:when test="PARAM[(@name='lr') and (@value='lang_sv')]">
      <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=ISO-8859-1"/>
    </xsl:when>
    <xsl:otherwise>
      <meta http-equiv="Content-Type" content="application/xhtml+xml; charset="/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<xsl:template name="langHeadEnd">
  <xsl:text disable-output-escaping="yes">&lt;/head&gt;</xsl:text>
</xsl:template>

<!-- **********************************************************************
 Utility functions for DOCTYPE and html elements (do not customize)
     ********************************************************************** -->
<xsl:template name="htmlStart">
  <xsl:text disable-output-escaping="yes">
&lt;!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"&gt;</xsl:text>
</xsl:template>
<xsl:template name="htmlEnd">
  <xsl:text disable-output-escaping="yes">&lt;/html&gt;</xsl:text>
</xsl:template>

<!-- **********************************************************************
 Utility functions (do not customize)
     ********************************************************************** -->

<!-- *** Find the substring after the last occurence of a separator *** -->
<xsl:template name="last_substring_after">

  <xsl:param name="string"/>
  <xsl:param name="separator"/>
  <xsl:param name="fallback"/>

  <xsl:variable name="newString"
    select="substring-after($string, $separator)"/>

  <xsl:choose>
    <xsl:when test="$newString!=''">
      <xsl:call-template name="last_substring_after">
        <xsl:with-param name="string" select="$newString"/>
        <xsl:with-param name="separator" select="$separator"/>
        <xsl:with-param name="fallback" select="$newString"/>
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$fallback"/>
    </xsl:otherwise>
  </xsl:choose>

</xsl:template>

<!-- *** Find and replace *** -->
<xsl:template name="replace_string">
  <xsl:param name="find"/>
  <xsl:param name="replace"/>
  <xsl:param name="string"/>
  <xsl:choose>
    <xsl:when test="contains($string, $find)">
      <xsl:value-of select="substring-before($string, $find)"/>
      <xsl:value-of select="$replace"/>
      <xsl:call-template name="replace_string">
        <xsl:with-param name="find" select="$find"/>
        <xsl:with-param name="replace" select="$replace"/>
        <xsl:with-param name="string"
          select="substring-after($string, $find)"/>
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$string"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>


<!-- **********************************************************************
 Display error messages
     ********************************************************************** -->
<xsl:template name="error_page">
  <xsl:param name="errorMessage"/>
  <xsl:param name="errorDescription"/>

  <xsl:call-template name="htmlStart"/>
  <xsl:call-template name="plainHeadStart"/><title><xsl:value-of select="$error_page_title"/></title>
  <xsl:call-template name="style"/>
  <xsl:call-template name="plainHeadEnd"/><body>
  <xsl:call-template name="my_page_header"/>

  <xsl:if test="$show_logo != '0'">
    <div><xsl:call-template name="logo"/></div>
  </xsl:if>

  <xsl:call-template name="top_sep_bar">
    <xsl:with-param name="text" select="$sep_bar_error_text"/>
    <xsl:with-param name="show_info" select="0"/>
    <xsl:with-param name="time" select="0"/>
  </xsl:call-template>

<dl>
<dt>Message:</dt>
<dd><xsl:value-of select="$errorMessage"/></dd>
<dt>Description:</dt>
<dd><xsl:value-of select="$errorDescription"/></dd>
<dt>Details:</dt>
<dd><xsl:copy-of select="/"/></dd>
</dl>

<hr/>
  <xsl:call-template name="copyright"/>
  <xsl:call-template name="my_page_footer"/>

</body>
  <xsl:call-template name="htmlEnd"/>
</xsl:template>

<!-- **********************************************************************
  OneBox results (if any)
     ********************************************************************** -->
<xsl:template name="onebox">
     <xsl:for-each select="/GSP/ENTOBRESULTS">
       <xsl:apply-templates/><hr />
     </xsl:for-each>
</xsl:template>

<!-- **********************************************************************
 Swallow unmatched elements
     ********************************************************************** -->
<xsl:template match="@*|node()"/>
</xsl:stylesheet>


<!-- *** END OF STYLESHEET *** -->